ServerEvents.recipes(event =>{
  const create = event.recipes.create
  const tfc = event.recipes.tfc
  const incomplete = 'create:incomplete_precision_mechanism'
  // const  minecraft = event.recipes.minecraft
  // event.remove({type:'minecraft:smelting'})
  // event.remove({type:'minecraft:blasting'})
  event.replaceInput({input:"minecraft:iron_ingot",not:{type:"immersiveengineering:arc_furance"}},'minecraft:iron_ingot','tfc:metal/ingot/wrought_iron')
  event.shaped('minecraft:bucket',['A A',' A '],{A:"firmalife:metal/sheet/stainless_steel"})
  event.remove({output:'minecraft:damaged_anvil'})
  event.remove({output:'minecraft:chipped_anvil'})
  event.remove({output:"tacz:gun_smith_table"})
  event.remove({input:'#forge:dusts/iron',output:'minecraft:iron_ingot'})
  event.remove({output:"immersive_aircraft:gyrodyne"})
  event.remove('immersive_aircraft:quadrocopter')
  event.remove('immersive_aircraft:airship')
  event.remove({output:'minecrft:stick',input:'tfc:stick_bunch'})
  event.replaceInput({output:'minecraft:scaffolding'},'minecraft:bamboo','tfc:stick_bunch')
  event.replaceInput({output:'minecraft:scaffolding'},'minecraft:string','#forge:string')
  //粉合成
  event.replaceOutput({input:'minecraft:iron_block',output:'minecraft:iron_ingot'},
  'minecraft:iron_ingot','tfc:metal/ingot/wrought_iron')
  event.replaceInput({output:'minecraft:iron_block',input:'minecraft:iron_ingot'},
  'minecraft:iron_ingot','tfc:metal/ingot/wrought_iron')
  event.replaceInput({output:"woodenhopper:wooden_hopper"},'#minecraft:planks','#tfc:lumber')
  event.replaceInput({},'minecraft:dried_kelp','tfc:food/dried_kelp')
  event.replaceInput({},'minecraft:potato','tfc:food/potato')
  event.replaceOutput({},'minecraft:potato','tfc:food/potato')

  create.compacting([Item.of('#forge:ingots/iron',9)],'minecraft:iron_block')
  create.mixing('immersiveengineering:dust_iron',[Item.of('tfc:powder/hematite',20)])
  create.mixing('immersiveengineering:dust_iron',[Item.of('tfc:powder/magnetite',20)])
  create.mixing('immersiveengineering:dust_iron',[Item.of('tfc:powder/limonite',20)])
  //转换
  create.haunting('minecraft:iron_ingot',['tfc:metal/ingot/cast_iron'])
  create.haunting('minecraft:gold_ingot',['tfc:metal/ingot/gold'])
  create.haunting('minecraft:diamond',['tfc:gem/diamond'])
  //树汁->树脂->助焊剂
  event.remove('thermal:device_tree_extractor')
  event.shaped('thermal:device_tree_extractor',
  [
    'ABA',
    'BCB',
    'ADA'
  ],
  {
    A:'#minecraft:planks',
    B:'create:fluid_pipe',
    C:'create:fluid_tank',
    D:"create:andesite_casing"
  })
  //修改create枪械
  event.replaceInput({output:'musketmod:blunderbuss'},
  'createaddition:iron_rod' , '#forge:rods/iron')
  event.replaceInput({output:'musketmod:blunderbuss'},
  'minecraft:iron_ingot' , 'tfc:metal/ingot/wrought_iron')
  event.replaceInput({output:'musketmod:musket'},
  'createaddition:brass_rod' , '#forge:rods/brass')
  event.remove('musketmod:cartridge')
  create.mixing([Item.of('musketmod:cartridge',6)],[Item.of('#forge:nuggets/iron',3),'minecraft:gunpowder','minecraft:paper'])
  create.mixing([Item.of('musketmod:cartridge',6)],[Item.of('#forge:nuggets/brass',3),'minecraft:gunpowder','minecraft:paper'])
  // 铁手杖
  event.remove('tfccanes:refined_walking_cane')
  tfc.anvil('tfccanes:refined_walking_cane','tfc:metal/double_ingot/wrought_iron',['hit_last','hit_not_last', 'upset_any']).bonus(true).tier(2)
  //纸
  event.remove({output:'htm:sawdust'})
  event.remove({input:'#forge:dusts/wood',output:'minecraft:paper'})
  //热力硝石
  event.shapeless('thermal:niter',Item.of('tfc:powder/saltpeter',4))
  event.remove({input:'tfc:metal/sheet/silver',output:'umapyoi:uma_select_block'})
  event.remove({output: 'enderio:void_chassis'})
  event.remove({output: 'enderio:grains_of_infinity'})
  event.remove({output: 'tfccanes:refined_walking_cane'})
  event.remove({output: 'ad_astra:tier_3_rocket'})
  event.shaped(
    Item.of('enderio:void_chassis', 1), // arg 1: output
    [
      'ABA',
      'BCB', // arg 2: the shape (array of strings)
      'ABA'
    ],
    {
      A: 'enderio:dark_steel_bars',
      B: '#forge:ingots/dark_steel',  //arg 3: the mapping object
      C: 'enderio:grains_of_infinity'
    
  })
  event.shapeless('minecraft:glass_bottle','#tfc:glass_bottles')
  event.shapeless('tfc:silica_glass_bottle','minecraft:glass_bottle')
  event.shapeless('minecraft:glass_bottle','create:builders_tea')
  //背包
  event.remove('backpacked:backpack')
  event.shaped(
    Item.of('backpacked:backpack', 1), 
    [
      'DED',
      'BCB', 
      'AAA'
    ],
    {
      A: 'kubejs:aluminum_alloy',
      B: 'immersiveengineering:stick_steel',  
      C: 'immersiveengineering:reinforced_crate',
      D: 'immersiveengineering:wire_steel',
      E: 'ae2:item_storage_cell_4k'
    })
  event.remove('immersive_aircraft:engine')
  event.shaped(
    Item.of('immersive_aircraft:engine', 1), 
    [
      'BAB ',
      'FCHG',
      'DED '
    ],
    {
      A: 'immersive_aircraft:boiler',
      B: 'immersiveengineering:sheetmetal_colored_gray',  
      C: 'create_new_age:heater',
      D: 'create:copper_casing',
      E: 'create:andesite_casing',
      F: 'create_new_age:heat_pipe',
      G: 'create:shaft',
      H: 'immersive_aircraft:sturdy_pipes'
    })//沉浸航空发动机
  //制作熔融安山合金
  create.mixing(Fluid.of('kubejs:melting_incompleted_andesite_alloy',100),[Item.of('kubejs:incompleted_andesite_alloy',1)]).heated()
  //沉静航空机身
  event.remove('immersive_aircraft:hull')
  create.sequenced_assembly([Item.of('immersive_aircraft:hull',2)],
  'firmalife:treated_wood',
  [   create.deploying(incomplete,[incomplete,'firmalife:treated_wood']),
      create.deploying(incomplete,[incomplete,'firmalife:treated_wood']),
      create.deploying(incomplete,[incomplete,'tfc_ie_addon:metal/sheet/aluminum']),
      create.deploying(incomplete,[incomplete,'immersiveengineering:stick_aluminum']),
      create.filling(incomplete,[Fluid.of('thermal:latex',1000),incomplete]),
      create.pressing(incomplete,incomplete)
  ]).transitionalItem(incomplete).loops(6);
  //铁砧修复
  event.smithing('minecraft:chipped_anvil','minecraft:damaged_anvil','tfc:metal/double_ingot/wrought_iron').template('tfc:metal/chain/wrought_iron')
  event.smithing('minecraft:anvil','minecraft:chipped_anvil','tfc:metal/double_ingot/wrought_iron').template('tfc:metal/chain/wrought_iron')
  event.smithing('minecraft:anvil','minecraft:damaged_anvil','minecraft:iron_block').template('tfc:metal/chain/wrought_iron')
  event.remove({output:'tfccanes:walking_cane'})
  event.shapeless('tfccanes:walking_cane',['minecraft:brick','minecraft:stick','minecraft:brick'])
  //精制工艺
  const prmai = ['prma:sulfur_powder','prma:flint_powder','prma:long_ammunition_gunpowder','prma:medium_ammunition_gunpowder','prma:small_ammunition_gunpowder']
  prmai.forEach(i =>{
      event.remove({output:i})
  })
  create.mixing('6x prma:long_ammunition_gunpowder',['#forge:dusts/sulfur','2x minecraft:gunpowder'])
  create.mixing('6x prma:medium_ammunition_gunpowder',['#forge:dusts/sulfur','minecraft:gunpowder'])
  create.mixing('6x prma:small_ammunition_gunpowder',['#forge:dusts/saltpeter','minecraft:gunpowder'])
  event.stonecutting('2x minecraft:amethyst_shard','tfc:gem/amethyst')
  event.shapeless('2x minecraft:scaffolding',['3x minecraft:string','minecraft:scaffolding'])

  event.remove({output:'tfc:stick_bundle'})
  event.remove({output:'minecraft:cauldron'})
  event.shaped('2x minecraft:cauldron',['ABA','BBB','ABA'],{A:"#forge:rods/iron",B:"#forge:plates/iron"})
  event.replaceInput({output:'anvilcraft:jewelcrafting_table'},'minecraft:smooth_stone','#tfc:rock/hardened')
  event.replaceInput({output:'minecraft:grindstone'},'minecraft:stone_slab','#minecraft:slabs')
  //飞机
  event.shaped('immersive_aircraft:airship',[
    ' AAA ','A E A','ACBCA','EDBDE',' DDD '
  ],
  {A:"immersive_aircraft:sail",B:"immersive_aircraft:boiler",C:"tfc:metal/ingot/wrought_iron",D:"immersive_aircraft:hull",E:"tfc:metal/chain/wrought_iron"
});
  event.remove('immersive_aircraft:sturdy_pipes')
  event.shaped('immersive_aircraft:sturdy_pipes',['BAB',' A ','BAB'],{A:'create:fluid_pipe',B:'immersiveengineering:plate_aluminum'})
  event.shaped('ad_astra:earth_globe',
  [
    ' GYY ',      
    ' GO  ',
    ' GYY ',
    '  Y  ',
    ' XXX '
  ],{
    X:'minecraft:light_weighted_pressure_plate',
    Y:'#forge:ingots/gold',
    G:'tfc:metal/rod/brass',
    O:'minecraft:crying_obsidian'
  }
)
  event.shapeless('minecraft:ladder','4x #forge:rods/wooden')
  event.replaceInput({output:'minecraft:stonecutter'},'minecraft:stone','#forge:stone')
  const colors = ['white', 'black', 'brown', 'blue', 'magenta', 'light_blue', 'yellow', 'orange', 'pink', 'gray', 'light_gray', 'cyan', 'purple', 'green', 'red','lime']
  colors.forEach(color =>{  event.custom({
    "type": "anvilcraft:anvil_processing",
    "anvil_recipe_type": "bulging_like",
    "icon": {
      "item": "anvilcraft:reinforced_concrete_light_gray"
    },
    "outcomes": [
      {
        "type": "spawn_item",
        "chance": 1.0,
        "offset": [ 0.0, -1.0, 0.0],
        "result": {"count": 16,"item": "anvilcraft:reinforced_concrete_"+color}}],
    "predicates": [
      {"type": "has_block",
        "match_block": {
          "blocks": ["anvilcraft:cement_cauldron"],"state": {"color": color}},
        "offset": [ 0.0, -1.0, 0.0]},
      {"type": "has_item_ingredient",
        "match_item": {
          "count": {
            "min": 2},"tag": "forge:gravel"},
        "offset": [ 0.0, -1.0,]},
      {"type": "has_item_ingredient",
        "match_item": {
          "count": {
            "min": 2
          },"tag": "minecraft:sand"},
        "offset": [ 0.0, -1.0, 0.0]},{
        "type": "has_item_ingredient",
        "match_item": {
          "count": {
            "min": 4
          },"items": ["minecraft:iron_bars"]},
        "offset": [ 0.0, -1.0, 0.0]}]
    })
  });
  event.custom({
    "type": "anvilcraft:anvil_processing",
    "anvil_recipe_type": "bulging_like",
    "icon": {
      "item": "anvilcraft:reinforced_concrete_light_gray"
    },
    "outcomes": [
      {
        "type": "spawn_item",
        "chance": 1.0,
        "offset": [ 0.0, -1.0, 0.0],
        "result": {"count": 16,"item": "anvilcraft:reinforced_concrete_gray"}}],
    "predicates": [
      {"type": "has_block",
        "match_block": {
          "blocks": ["anvilcraft:cement_cauldron"],"state": {"color": "gray"}},
        "offset": [ 0.0, -1.0, 0.0]},
      {"type": "has_item_ingredient",
        "match_item": {
          "count": {
            "min": 2},"tag": "forge:gravel"},
        "offset": [ 0.0, -1.0,]},
      {"type": "has_item_ingredient",
        "match_item": {
          "count": {
            "min": 2
          },"tag": "minecraft:sand"},
        "offset": [ 0.0, -1.0, 0.0]},{
        "type": "has_item_ingredient",
        "match_item": {
          "count": {
            "min": 4
          },"items": ["minecraft:iron_bars"]},
        "offset": [ 0.0, -1.0, 0.0]}]
    })
  event.custom({
    "type": "anvilcraft:anvil_processing",
    "anvil_recipe_type": "generic",
    "icon": {
      "item": "tfc:mortar"
    },
    "outcomes": [
      {
        "type": "set_block",
        "chance": 1.0,
        "offset": [ 0.0, -1.0, 0.0],
        "result": {
          "block": "anvilcraft:cement_cauldron",
          "state": {
            "color": "gray"}}}],
    "predicates": [
      {
        "type": "has_block",
        "match_block": {
          "blocks": [
            "minecraft:water_cauldron"
          ],
          "state": {
            "level": "3"
          }
        }, "offset": [ 0.0, -1.0, 0.0]},
      {"type": "has_item_ingredient",
        "match_item": {
          "count": {
            "min": 2
          },
          "tag": "forge:gravel"},
        "offset": [ 0.0, -1.0,]},
      {"type": "has_item_ingredient",
        "match_item": {
          "count": {
            "min": 2
          },
          "items": ["tfc:mortar"]},
        "offset": [ 0.0, -1.0, 0.0]}]
  })
  event.shaped('goety:quick_growing_seed',['ABA','BCB','ABA'],{A:"minecraft:bone_meal",B:"immersiveengineering:fertilizer",C:"#forge:seeds"})
  event.shaped('4x create:belt_connector',['AAA','BAB','AAA'],{A:"htm:rope",B:"#forge:leather"})
  //lyche合成
  event.custom({
    "type": "lychee:block_interacting",
    "item_in": {
        "item": "minecraft:flint"
    },
    "block_in": "tfc:metal/anvil/steel",
    "post":[{
      "type": "drop_item",
      "item": "enderio:grains_of_infinity"
    }]
  });
  event.custom({
    "type": "lychee:block_interacting",
    "item_in": {
      "item": "enderio:grains_of_infinity"
    },
    "block_in": "#forge:cobblestone",
    "post":[{
      "type": "place",
      "block": "minecraft:cobbled_deepslate"
  }]
  });
  event.custom({
    "type": "lychee:block_interacting",
    "item_in": {"tag": "tfc:dirt"},
    "block_in": "minecraft:sculk_vein",
    "post":[{
      "type": "drop_item",
      "item": "minecraft:sculk"},{"type": "place","block": "minecraft:air"}]
  });
  event.custom({
    "type": "lychee:block_interacting",
    "item_in": {"tag": "tfc:mud"},
    "block_in": "minecraft:sculk_vein",
    "post":[{
      "type": "drop_item",
      "item": "minecraft:sculk"},{"type": "place","block": "minecraft:air"}]
  });
  event.custom({
    "type": "lychee:block_interacting",
    "item_in": {"tag": "tfc:grass"},
    "block_in": "minecraft:sculk_vein",
    "post":[{
      "type": "drop_item",
      "item": "minecraft:sculk"},
    {"type": "place","block": "minecraft:air"}]
  });
  event.custom({
    "type": "lychee:block_interacting",
    "item_in": {"tag": "forge:seeds"},
    "block_in": "minecraft:sculk_vein",
    "post":[{
      "type": "drop_item",
      "item": "goety:quick_growing_seed"
  },{"type": "place","block": "minecraft:air"}]
  });
  event.custom({
    "type": "lychee:block_interacting",
    "item_in": {"item": "tfc:wooden_bucket"},
    "block_in": "minecraft:powder_snow_cauldron",
    "post":[{
      "type": "drop_item",
      "item": "kubejs:powder_snow_woodden_bucket"
  },{"type": "place","block": "minecraft:cauldron"}]
  });
  event.custom({
    "type": "lychee:block_interacting",
    "item_in": {"item": "kubejs:gluttony"},
    "block_in":"goety:necro_brazier",
    "post":[{
      "type": "execute",
      "command": "fillbiome ~ ~ ~ ~ ~ ~ minecraft:deep_dark",
  }]
  });
  event.custom({
    "type": "lychee:block_interacting",
    "item_in": {"item": "enderio:skeletal_contractor"},
    "block_in":"minecraft:beacon",
    "post":[
      {
      "type": "execute",
      "command": "summon mobz:withender ~ ~5 ~"},
      {
        "type": "execute",
        "command": "summon minecraft:lightning_bolt ~ ~ ~"}]
  });
})
